Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Nov 13, 2025

Summary

  • implement file_edit_insert with optional before/after substring guards plus line_offset fallback, including new runtime tool + unit coverage
  • wire the tool through type defs, tokenizer accounting, redaction, and UI rendering so agents can call it safely
  • refresh tool policy + runtime IPC tests to favor file_edit_insert and ensure redactors/tests understand the new tool

Testing

  • make typecheck
  • make test

Generated with mux

@ammar-agent ammar-agent force-pushed the remove-file-edit-insert branch from 5f3cdbc to 3791c66 Compare November 13, 2025 19:44
@ammar-agent ammar-agent changed the title 🤖 refactor: remove file_edit_insert tool 🤖 feat: add guard-anchored file_edit_insert tool Nov 14, 2025
@ammar-agent ammar-agent marked this pull request as draft November 14, 2025 02:21
@ammar-agent ammar-agent force-pushed the remove-file-edit-insert branch from 565c5eb to 79e3c6b Compare November 14, 2025 17:17
root and others added 8 commits November 14, 2025 17:49
The file_edit_insert tool led to more issues than benefits (unreliable line offset calculations and edge cases). Standardize on file_edit_replace_string as the primary file editing tool.

Changes:
- Remove file_edit_insert tool and all references
- Remove from tool definitions and type exports
- Update UI components to only support replace_string and replace_lines
- Update tests and tool policies
- Update integration tests to use file_edit_replace_string

All 987 unit tests pass; typecheck is clean.
@ammar-agent ammar-agent force-pushed the remove-file-edit-insert branch from 73098b7 to d9622c3 Compare November 14, 2025 17:49
@ammario ammario marked this pull request as ready for review November 14, 2025 18:07
@ammario ammario merged commit c76e501 into main Nov 14, 2025
13 checks passed
@ammario ammario deleted the remove-file-edit-insert branch November 14, 2025 18:08
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +130 to +143
function insertContent(
originalContent: string,
contentToInsert: string,
options: InsertContentOptions
): InsertOperationSuccess | InsertOperationFailure {
const { before, after } = options;

if (before !== undefined && after !== undefined) {
return guardFailure("Provide only one of before or after (not both).");
}

if (before === undefined && after === undefined) {
return guardFailure("Provide either a before or after guard to anchor the insertion point.");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Allow file_edit_insert to work on existing empty files

The new insert helper always returns an error when neither before nor after guards are provided, which means there is no way to write into an existing empty file—the file has no substrings to anchor against, and the create flag is ignored once the file already exists. Any invocation against a zero‑byte file will therefore always fail with “Provide either a before or after guard…”, making the tool unusable for initializing empty files (a capability the previous line_offset API supported). Consider falling back to inserting at the top of the file when it is empty or when guards are omitted, so agents can still populate empty files without resorting to other tools.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants